package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.LiveType;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.LiveTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 邵康
 * @date 2021/11/26 16:56
 */
@Api(tags = "直播类型管理")
@CrossOrigin
@RestController
@RequestMapping("/liveType")
public class LiveTypeController {

    @Autowired
    private LiveTypeService liveTypeService;

    @ApiOperation("添加直播类型  只有  info可以省略  cover 使用预定义图")
    @PostMapping("/add")
    public R<Void> add(LiveType liveType) {
        return liveTypeService.add(liveType);
    }

    @ApiOperation("deleteRes")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return liveTypeService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(LiveType liveType) {
        return liveTypeService.update(liveType);
    }

    @ApiOperation("pageSearch")
    @GetMapping("/page")
    public R<IPage<LiveType>> page(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer size) {
        return liveTypeService.page(page, size);
    }

    @ApiOperation("获取所有直播类型")
    @GetMapping("/getAll")
    public R<List<LiveType>> getAll(){
        return liveTypeService.getAll();
    }

}
